package singleton.type8;

/**
 * 枚举单例 <br>
 * Effective Java推荐的方式<br>
 * 结论: 推荐使用
 * @author yi qiang
 * @date 2021/5/2 22:07
 */
public class Singleton8 {

    public static void main(String[] args) {
        Singleton singleton=Singleton.getInstance();
        Singleton singleton2=Singleton.getInstance();
        System.out.println(singleton==singleton2);
    }


}

enum  Singleton{

    /**
     * 单例模式
     */
    INSTANCE;

    public static Singleton getInstance(){
        return INSTANCE;
    }
    

}
